home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / thesource6.dms / thesource6.adf / Source / Compression / hcompress.lha / hcompress / vms / fcompress.com < prev    next >
Encoding:
Text File  |  1992-05-12  |  3.2 KB  |  120 lines

  1. $! fcompress.com
  2. $!
  3. $! VMS command file to do H-transform image compression for a list of image
  4. $! files in FITS format.  Files are replaced by name.ext_H.
  5. $!
  6. $! Program will compress only I*2 images with no group parameters.
  7. $! (A warning is issued for other images.)
  8. $!
  9. $! The default compression scale factor is 666, which is appropriate for
  10. $! gasp images (gives about a factor of 10 compression, negligible loss in
  11. $! information.)
  12. $!
  13. $! R. White, 20 April 1992
  14. $!
  15. $! determine where this procedure lives (assume that the executable files
  16. $! are in this same directory)
  17. $!
  18. $ shellfile=f$parse(f$environment("procedure"),,,,"NO_CONCEAL")-"]["
  19. $ cdir=f$extract(0,f$locate("]",shellfile),shellfile) + "]"
  20. $ prgnam=f$parse(shellfile,,,"NAME")
  21. $!
  22. $ echo:=write sys$output
  23. $ hc:=$'cdir'hcomp
  24. $!
  25. $ if p1.eqs.""
  26. $ then
  27. $    echo "Usage: ",prgnam," [options] files... [options] files..."
  28. $    echo "  where options are:"
  29. $    echo "     -s scale to specify the compression scale factor"
  30. $    echo "     -k       to keep the uncompressed file (default)"
  31. $    echo "     -r       to remove the uncompressed file"
  32. $    echo ""
  33. $    echo "Default compression scale factor is 666 (good for GASP images.)"
  34. $    echo "Compressed files are named *.*_H."
  35. $    exit
  36. $ endif
  37. $!
  38. $ scale=666
  39. $ nextscale=0
  40. $ remove=0
  41. $ p=1
  42. $ ploop:
  43. $   parm = p'p
  44. $   if parm.eqs."" then exit                ! all done
  45. $   if nextscale.eq.1
  46. $   then
  47. $      scale=parm                    ! set scale
  48. $      nextscale=0
  49. $      echo "Using scale ", scale
  50. $      goto endploop
  51. $   endif
  52. $   if parm.eqs."-S"
  53. $   then
  54. $      nextscale=1                    ! next parm is scale
  55. $      goto endploop
  56. $   endif
  57. $   if parm.eqs."-R"
  58. $   then
  59. $      remove=1                        ! remove original files
  60. $      goto endploop
  61. $   endif
  62. $   if parm.eqs."-K"
  63. $   then
  64. $      remove=0                        ! keep original files
  65. $      goto endploop
  66. $   endif
  67. $!
  68. $! compress the file(s) specified by this parameter
  69. $! use f$search to allow the use of wildcards in file specifications
  70. $!
  71. $   datafile=f$search(parm,1)                ! get original file name
  72. $   if datafile.eqs.""
  73. $   then
  74. $      echo prgnam,": ",datafile,": No such file"
  75. $      goto endploop
  76. $   endif
  77. $!
  78. $! save name of first file to correct the stupid behavior of f$search
  79. $! when the file argument does not contain a wildcard character
  80. $!
  81. $   firstfile=datafile
  82. $ floop:
  83. $      dext=f$parse(datafile,,,"TYPE")
  84. $      cext=dext+"_H"
  85. $      compfile=f$parse(cext+";",datafile,,,"SYNTAX_ONLY")    ! compress name
  86. $!
  87. $! if compressed file already exists, we'll rely on VMS to create a new version
  88. $!
  89. $!
  90. $! perform compression
  91. $!
  92. $      echo datafile
  93. $      define/user sys$output 'compfile'
  94. $      hc -v -s 'scale' -i fits 'datafile'
  95. $      if $status.eq.1                ! check for success
  96. $      then
  97. $         if remove.eq.1 then delete 'datafile'    ! delete original file
  98. $      else
  99. $         echo prgnam,": ",datafile," not compressed: compression error"
  100. $         delete 'compfile'                ! delete compressed file
  101. $      endif
  102. $ endfloop:
  103. $!
  104. $! get next file name
  105. $!
  106. $! be careful: f$search returns the same name every time if there are
  107. $! no wildcard characters in the argument (dumb)
  108. $!
  109. $      datafile=f$search(parm,1)
  110. $      if datafile.nes.firstfile
  111. $      then
  112. $         if datafile.nes."" then goto floop
  113. $      endif
  114. $!
  115. $! go to next parameter
  116. $!
  117. $ endploop:
  118. $   p = p+1
  119. $   goto ploop
  120.